import socket
from sys import stdin

from conf import get_conf

socket_conf = get_conf()

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 客户端连接端口
sock.connect(socket_conf)

print(sock.recv(1024).decode('utf-8'))

print('Please input your msg:')

msg = stdin.readline()

sock.send(msg.encode('utf-8'))

while True:
    data = sock.recv(1024)
    if not data or data.decode('utf-8') == 'exit':
        # print(data)
        break
    else:
        print(data.decode('utf-8'))
        print('Please input your msg:')
        msg = stdin.readline()
        sock.send(msg.encode('utf-8'))
